package cn.wolfcode.redis.util;

import cn.wolfcode.util.Consts;
import lombok.Getter;

@Getter
public enum RedisKeys {
    BRUSH_PROOF("brush_proof", 60L), // 1min
    REGIST_VERIFY_CODE("regist_verify_code", 60L * Consts.VERIFY_CODE_TIME),
    USER_LOGIN_TOKEN("user_login_token", 60L * Consts.USER_INFO_TOKEN_VAI_TIME),
    STRATEGY_STATIS_VO("strategy_statis_vo", -1L),
    STRATEGY_THUMBSUP("strategy_thumbsup", -1L),
    BLACK_LIST("black_list", 60L *60 * 24), // 1天
    // 用户违规次数
    ILLEGAL_COUNT("illegal_count", 60L * 60 * 24),
    USER_STRATEGY_FAVOR("user_strategy_favor", -1L);
    // 前缀
    private String prefix;
    // 过期时间
    private Long time;

    RedisKeys(String prefix, Long time) {
        this.prefix = prefix;
        this.time = time;
    }

    /**
     * 拼接key
     *
     * @param args
     * @return
     */
    public String join(String... args) {
        StringBuffer sb = new StringBuffer();
        sb.append(this.prefix);
        for (String arg : args) {
            sb.append(":").append(arg);
        }
        return sb.toString();
    }
}
